home *** CD-ROM | disk | FTP | other *** search
/ Inside Indy 1993 / Inside Indy 1993.iso / demos / CHEM / ribbon / bin / pdb-model < prev    next >
Encoding:
Text File  |  1993-06-23  |  740 b   |  34 lines

  1. #!/bin/csh
  2.  
  3. #  usage:
  4. #        pdb-model  file.pdb  file.model
  5. #
  6. #  create a *.model file for ribbons
  7. #  script generates temporary files in the current directory!
  8.  
  9. #  temporary files, with current process appended "$$"
  10. set model = pdbmod.$$
  11. set awkfile = pdbcom.$$
  12. set awkout  = pdbout.$$
  13.  
  14. cat  <<'EOF'  > $awkfile
  15. BEGIN { xc=0.0; yc=0.0; zc=0.0; n=0; }
  16. $1=="ATOM" || $1=="HETATM"    {
  17.         x = 0.0 + substr($0,31,8);
  18.         y = 0.0 + substr($0,39,8);
  19.         z = 0.0 + substr($0,47,8);
  20.         xc += x;
  21.         yc += y;
  22.         zc += z;
  23.         n++;
  24.     }
  25. END { if(n) { xc/=n; yc/=n; zc/=n; } \
  26.     printf(" %.2f %.2f %.2f  (~Center-of-Mass for %d atoms)\n",xc,yc,zc,n);}
  27. 'EOF'
  28.  
  29. echo $1:r > $model
  30. awk -f $awkfile < $1 > $awkout
  31. paste $model $awkout > $2
  32.  
  33. /bin/rm -f $model $awkfile $awkout
  34.